<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- 		<link rel="stylesheet" href="http://design.rtve.int/beatrizjc/trato/style.css" type="text/css" media="screen" /> -->
		<link href="/trato/resources/css/style.css" rel="stylesheet"/>
		<script src="/trato/resources/js/jquery-1.11.0.min.js"></script>
		<script type="text/javascript">
			function ejecutarAccion(id){
				 $.ajax({
					 type: "POST",
					 url: "cambiarEstado",
					 data: "id=" + id + "&enabled=" + $("#"+id).is(':checked'),
					 success: function(response){}
				 });
			};
		</script>
	</head>
	<body>
		<c:import url="header.jsp" />
		
			<h3><fmt:message key="administrador.manageUsers"/></h3>
		
		<table class="admin_panel">
			<tr>
				<td><fmt:message key="administrador.panel.name"/></td>
				<td><fmt:message key="administrador.panel.email"/></td>
				<td><fmt:message key="administrador.panel.enabled"/></td>
			</tr>
			<c:forEach var="cliente" items="${usuarios}">
				<tr>
					<td><c:out value="${cliente.nombre}"/> <c:out value="${cliente.apellido1}"/><c:out value="${cliente.apellido2}"/></td>
					<td><c:out value="${cliente.getUsername()}"/></td>
					<td>
						<input id="${cliente.getId()}" type="checkbox" name="clienteId" value="${cliente.getId()}" <c:if test="${cliente.getEnabled()}">checked='checked'</c:if> onclick="ejecutarAccion(${cliente.getId()});"/>
					</td>
				</tr>
			</c:forEach>
		</table>
		<div class="pagination">
			<c:if test="${page>1}">
				<span><a href="home?page=${page-1}"><fmt:message key="pagination.prev"/></a></span>
			</c:if>
			<span><fmt:message key="pagination.page"/><em><c:out value="${page}" /></em><fmt:message key="pagination.of"/><em><c:out value="${totalPages}" /></em></span>
			<input type="hidden" id="page" name="page" value="${page}"/>
			<c:if test="${totalPages>page}">
				<span><a href="home?page=${page+1}"><fmt:message key="pagination.next"/></a></span>
			</c:if>
		</div>
	</body>
</html>